Parameter expansion in Bash is a powerful feature that allows for the manipulation and transformation of shell variables and other parameters. It utilizes a special syntax, typically involving curly braces and various operators, to perform operations such as extracting substrings, replacing parts of a string, setting default values, or modifying case. Here are some common types of parameter expansion: Simple Expansion: ${parameter} substitutes the value of the parameter. This is equivalent to $parameter but is often preferred for clarity and to avoid ambiguity when concatenating with other strings. Código my_var="hello" echo "${my_var} world" # Output: hello world Default Values: ${parameter:-word}: If parameter is unset or null, it expands to word. Otherwise, it expands to the value of parameter. ${parameter:=word}: If parameter is unset or null, it expands to word and parameter is set to word. Otherwise, it expands to the value of parameter. Código unset my_var echo "${my_var:-default}" # Output: default my_var="value" echo "${my_var:-default}" # Output: value Error Handling: ${parameter:?word}: If parameter is unset or null, it prints word to standard error and exits the shell. Otherwise, it expands to the value of parameter. Código unset my_var echo "${my_var:?Error: my_var is not set}" # Exits with error message Substring Extraction: ${parameter:offset}: Extracts a substring starting from offset. ${parameter:offset:length}: Extracts a substring of length characters starting from offset. Código string="abcdefg" echo "${string:2}" # Output: cdefg echo "${string:2:3}" # Output: cde Removing Prefixes/Suffixes: ${parameter#pattern}: Removes the shortest matching prefix pattern. ${parameter##pattern}: Removes the longest matching prefix pattern. ${parameter%pattern}: Removes the shortest matching suffix pattern. ${parameter%%pattern}: Removes the longest matching suffix pattern. Código filename="image.tar.gz" echo "${filename%.gz}" # Output: image.tar echo "${filename##*.}" # Output: gz String Length: ${#parameter} expands to the length of the value of parameter. Código name="Bash" echo "${#name}" # Output: 4 These are just some of the common uses of parameter expansion in Bash, offering a flexible and efficient way to work with variables in shell scripts.